#include<bits/stdc++.h>
using namespace std;
#define int long long

int cnt[10][1000005];

signed main() {
	for (int i = 1; i <= 1000000; i++) {
		for(int j = 0; j <= 9; j++){
			cnt[j][i] = cnt[j][i-1];
		}
		int x = i;
		while (x) {
			cnt[x % 10][i]++;
			x /= 10;
		}
	}

	int l, r, n;
	cin >> l >> r >> n;
	cout << cnt[n][r] - cnt[n][l - 1];
	return 0;
}
